Skip to content

Add session description baggage support - #80

Merged
fpfp100 merged 8 commits into
mainfrom
copilot/add-session-description-baggage-support
Nov 21, 2025
Merged

Add session description baggage support#80
fpfp100 merged 8 commits into
mainfrom
copilot/add-session-description-baggage-support

Conversation

Copilot AI commented Nov 20, 2025

Copy link
Copy Markdown
Contributor

Adds OpenTelemetry baggage propagation for session descriptions, enabling contextual metadata to flow through distributed traces.

Changes

  • Constants: Added GEN_AI_SESSION_DESCRIPTION_KEY = 'gen_ai.session.description' to OpenTelemetry constants
  • BaggageBuilder: Added sessionDescription(value: string | null | undefined) fluent setter using existing set helper
  • Span Propagation: Included GEN_AI_SESSION_DESCRIPTION_KEY in GENERIC_ATTRIBUTES array for automatic span attribute enrichment
  • Tests: Added coverage for baggage entry setting and span attribute propagation
  • Sample: Demonstrated usage in basic-agent-sdk-sample

Usage

const baggageScope = new BaggageBuilder()
  .tenantId(tenantInfo.tenantId)
  .agentId(agentInfo.agentId)
  .sessionDescription('Initial onboarding session')
  .build();

baggageScope.run(async () => {
  // Session description propagates to all spans in this context
});
Original prompt

Simple change: add session description baggage support.

Scope:

  1. Add OpenTelemetry constant GEN_AI_SESSION_DESCRIPTION_KEY = 'gen_ai.session.description' in packages/agents-a365-observability/src/tracing/constants.ts near existing GEN_AI_AGENT_DESCRIPTION_KEY.
  2. Add fluent setter sessionDescription(value: string | null | undefined): BaggageBuilder to packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts (adjacent to sessionId and agentDescription methods). Reuse private set helper.
  3. Update propagation list in packages/agents-a365-observability/src/tracing/processors/util.ts (array of consts) to include GEN_AI_SESSION_DESCRIPTION_KEY so it becomes a span attribute.
  4. Tests:
    • Extend tests/observability/core/BaggageBuilder.test.ts with a test verifying builder.sessionDescription('My session desc') sets baggage entry.
    • Extend tests/observability/core/SpanProcessor.test.ts to assert a span created under baggage containing GEN_AI_SESSION_DESCRIPTION_KEY has the attribute (similar pattern to other baggage keys).
  5. Optional sample update: In tests-agent/basic-agent-sdk-sample/src/agent.ts add chained .sessionDescription('Initial onboarding session').

Keep description minimal per request. Do not modify unrelated code.

This pull request was created as a result of the following prompt from Copilot chat.

Simple change: add session description baggage support.

Scope:

  1. Add OpenTelemetry constant GEN_AI_SESSION_DESCRIPTION_KEY = 'gen_ai.session.description' in packages/agents-a365-observability/src/tracing/constants.ts near existing GEN_AI_AGENT_DESCRIPTION_KEY.
  2. Add fluent setter sessionDescription(value: string | null | undefined): BaggageBuilder to packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts (adjacent to sessionId and agentDescription methods). Reuse private set helper.
  3. Update propagation list in packages/agents-a365-observability/src/tracing/processors/util.ts (array of consts) to include GEN_AI_SESSION_DESCRIPTION_KEY so it becomes a span attribute.
  4. Tests:
    • Extend tests/observability/core/BaggageBuilder.test.ts with a test verifying builder.sessionDescription('My session desc') sets baggage entry.
    • Extend tests/observability/core/SpanProcessor.test.ts to assert a span created under baggage containing GEN_AI_SESSION_DESCRIPTION_KEY has the attribute (similar pattern to other baggage keys).
  5. Optional sample update: In tests-agent/basic-agent-sdk-sample/src/agent.ts add chained .sessionDescription('Initial onboarding session').

Keep description minimal per request. Do not modify unrelated code.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 20, 2025
- Add GEN_AI_SESSION_DESCRIPTION_KEY constant
- Add sessionDescription() fluent setter to BaggageBuilder
- Update GENERIC_ATTRIBUTES to propagate session description
- Add tests for sessionDescription in BaggageBuilder and SpanProcessor
- Update sample agent to use sessionDescription

Co-authored-by: fpfp100 <126631706+fpfp100@users.noreply.github.com>
Copilot AI changed the title [WIP] Add session description baggage support in observability Add session description baggage support Nov 20, 2025
Copilot AI requested a review from fpfp100 November 20, 2025 01:04
@fpfp100
fpfp100 marked this pull request as ready for review November 20, 2025 01:20
@fpfp100
fpfp100 requested review from a team as code owners November 20, 2025 01:20
Copilot AI review requested due to automatic review settings November 20, 2025 01:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds OpenTelemetry baggage propagation support for session descriptions, enabling contextual session metadata to flow through distributed traces alongside existing baggage attributes.

  • Introduces a new GEN_AI_SESSION_DESCRIPTION_KEY constant for the baggage key
  • Adds a fluent sessionDescription() setter to BaggageBuilder following existing patterns
  • Enables automatic propagation of session description from baggage to span attributes

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/agents-a365-observability/src/tracing/constants.ts Adds GEN_AI_SESSION_DESCRIPTION_KEY constant alongside existing agent/session constants
packages/agents-a365-observability/src/tracing/middleware/BaggageBuilder.ts Adds sessionDescription() fluent setter method and improves type safety in setPairs() method (changes any to unknown)
packages/agents-a365-observability/src/tracing/processors/util.ts Includes session description key in GENERIC_ATTRIBUTES array for span enrichment
tests/observability/core/BaggageBuilder.test.ts Adds test coverage for session description baggage entry setting and null value handling
tests/observability/core/SpanProcessor.test.ts Verifies session description propagates from baggage to span attributes
tests-agent/basic-agent-sdk-sample/src/agent.ts Demonstrates usage by adding session description to baggage builder chain

Comment thread tests/observability/core/BaggageBuilder.test.ts Outdated
Comment thread packages/agents-a365-observability/src/tracing/constants.ts Outdated
@fpfp100
fpfp100 enabled auto-merge (squash) November 20, 2025 19:35
Comment thread packages/agents-a365-observability/src/tracing/constants.ts Outdated
@fpfp100
fpfp100 merged commit 05ee041 into main Nov 21, 2025
7 checks passed
@nikhilNava
nikhilNava deleted the copilot/add-session-description-baggage-support branch November 21, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants